//
//  LoginPWDViewController.m
//  AntsExpress
//
//  Created by Home on 16/1/16.
//  Copyright © 2016年 slccper. All rights reserved.
//

#import "LoginPWDViewController.h"

@interface LoginPWDViewController ()
@property (weak, nonatomic) IBOutlet UITextField *old;
@property (weak, nonatomic) IBOutlet UITextField *newtext;
@property (weak, nonatomic) IBOutlet UITextField *Renew;

@end

@implementation LoginPWDViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ants = [[clsAntsService alloc]init];
    ants.delegate=self;
    self.old.text = [clsOtherFun getPwd];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)ChangeAction:(id)sender {
    NSString *newtext = self.newtext.text;
    if ([newtext isEqualToString:@""]) {
        [clsOtherFun ShowMsg:@"請輸入新密碼"];
        [self.newtext becomeFirstResponder];
        return;
    }
    NSString *Renew = self.Renew.text;
    if ([Renew isEqualToString:@""]) {
        [clsOtherFun ShowMsg:@"請確認新密碼"];
        [self.Renew becomeFirstResponder];
        return;
    }
    if (![newtext isEqualToString:Renew]) {
        [clsOtherFun ShowMsg:@"兩次密碼不一致"];
        [self.Renew becomeFirstResponder];
        return;
    }
    
    [clsOtherFun showLoadingView:@"正在更新數據..."];
    [ants Updateuserpwd:Renew];
}
-(void)getAntsDataSuccess:(NSInteger)type :(NSMutableDictionary *)pDictionary
{
    [clsOtherFun hideLoadingView];
    NSDictionary *dic = [pDictionary objectForKey:@"data"];
    NSString *status = [dic objectForKey:@"status"];
    if ([status integerValue]==200) {
        [clsOtherFun ShowMsg:@"更新成功！"];
        [self.navigationController popViewControllerAnimated:YES];
    }else{
        [clsOtherFun ShowMsg:[dic objectForKey:@"message"]];
    }

}

@end
